/**
 * Created with IntelliJ IDEA.
 * User: zhengry
 * Date: 2014/11/18
 * Time: 15:43
 */
define('framework/directive/GillionDirectiveModule', [
    'angular',
    'framework/directive/I18NLoaderConstructor',
    'framework/directive/GillionValidatorConstructor',
    'framework/directive/GillionResourceConstructor',
    'framework/directive/GillionCommonsQueryConstructor',
    'framework/directive/GillionCommonsSaveConstructor',
    'framework/directive/ControlValidatorServiceConstructor',
    'framework/directive/FieldValidatorDirectiveConstructor',
    'framework/validation/IllegalMessagesConstructor',
    'framework/validation/TooltipMessengerConstructor',
    'framework/validation/ValidationHolder',
    'framework/validation/ValidationErrorInterceptor',
    'framework/validation/ValidationErrorResponder',
    'framework/tooltip/GillionTooltipModule'
], function (angular,
             I18NLoaderConstructor,
             GillionValidatorConstructor,
             GillionResourceConstructor,
             GillionCommonsQueryConstructor,
             GillionCommonsSaveConstructor,
             ControlValidatorServiceConstructor,
             FieldValidatorDirectiveConstructor,
             IllegalMessagesConstructor,
             TooltipMessengerConstructor,
             ValidationHolder,
             ValidationErrorInterceptor,
             ValidationErrorResponder) {
    return angular.module('GillionDirectiveModule', ['GillionTooltipModule'], ['$compileProvider', '$provide', '$httpProvider', function ($compileProvider, $provide, $httpProvider) {

        $provide.factory('I18NLoader', I18NLoaderConstructor);
        $provide.factory('ControlValidatorService', ControlValidatorServiceConstructor);
        $provide.factory('ValidationHolder', ValidationHolder);
        $provide.factory('ValidationErrorResponder', ValidationErrorResponder);

        $compileProvider.directive('gValidator', GillionValidatorConstructor);

        $compileProvider.directive('gResource', GillionResourceConstructor);

        $compileProvider.directive('gCommonsQuery', GillionCommonsQueryConstructor);

        $compileProvider.directive('gCommonsSave', GillionCommonsSaveConstructor);

        $compileProvider.directive('gFieldValidator', FieldValidatorDirectiveConstructor);

        $provide.factory('IllegalMessages', IllegalMessagesConstructor);
        $provide.factory('tooltipMessenger', TooltipMessengerConstructor);

        $httpProvider.interceptors.push(ValidationErrorInterceptor);

    }]);
});